package exp4;

import java.util.Arrays;
import java.util.Scanner;

public class NumberSort {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] a = new int[1];
        int i = 0;
        while (in.hasNext()) {
            if (i == a.length) {
                int[] b = new int[a.length * 2];
                System.arraycopy(a, 0, b, 0, a.length);
                a = b;
            }
            a[i++] = in.nextInt();
        }
        Arrays.sort(a, 0, i);
        int j;
        for (j=0;j<i;j++) {
            System.out.print( a[j] + " ");
        }
        System.out.println();
        int recent = a[i-1];
        for (j = i -1; j >= 0; j--) {
            if (a[j] == recent) continue;
            System.out.print( recent+" " );
            recent = a[j];
        }
        System.out.print(recent);
    }
}
